package 测试;

public class Test1 {
    //所有子序列

    void subset(int[] nums, int[] temp, int k){
        if(k> nums.length)
            return;
        else if(k== nums.length){
            for (int i = 0; i < nums.length; i++) {
                if(temp[i]==1)
                    System.out.printf("%d ",nums[i]);
            }
            System.out.println(" ");
            return;
        }
        temp[k]=0;
        subset(nums,temp,k+1);
        temp[k]=1;
        subset(nums,temp,k+1);
    }
    public static void main(String[] args) {
        int[] nums = new int[]{1,2,3,4};
        int[] temp = new int[nums.length];
        new Test1().subset(nums,temp,0);

    }
}
